package com.kfc.platform.transaction.service.impl;


import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.kfc.platform.transaction.dao.TradeHistoryDao;
import com.kfc.platform.transaction.dao.TransactionDao;
import com.kfc.platform.transaction.dao.impl.TransactionDaoImpl;
import com.kfc.platform.transaction.domain.TradeHistory;
import com.kfc.platform.transaction.domain.TradeList;
import com.kfc.platform.transaction.service.TradeHistoryService;
import com.kfc.platform.transaction.service.TransactionService;
import com.kfc.platform.user.dao.UserDao;
import com.kfc.platform.user.domain.User;

public class TradeHistoryServiceImpl implements TradeHistoryService{
	private TradeHistoryDao tradehistoryDao ;

	public TradeHistoryDao getTradehistoryDao() {
		return tradehistoryDao;
	}

	public void setTradehistoryDao(TradeHistoryDao tradehistoryDao) {
		this.tradehistoryDao = tradehistoryDao;
	}

	@Override
	public String createTradeHistory(TradeHistory tradehistory) {
		// TODO Auto-generated method stub
		TradeHistory inserthistory = new TradeHistory();
		inserthistory.setAmount(tradehistory.getAmount());
		inserthistory.setPrice(tradehistory.getPrice());
		inserthistory.setList_time(tradehistory.getList_time());
		inserthistory.setListnum(tradehistory.getListnum());
		inserthistory.setUsername(tradehistory.getUsername());
		inserthistory.setType(tradehistory.getType());
		inserthistory.setStatus(tradehistory.getStatus());
		inserthistory.setSum(tradehistory.getSum());
		System.out.println("from:"+tradehistory.getUsername());
		if(inserthistory == null){
			throw new IllegalArgumentException("transaction must be not null.");
		}
		tradehistoryDao.save(inserthistory);
		return "插入数据库成功！";
	}

	@Override
	public void getTradeHistory(String reg) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public String createTradeHistory(TradeList tradeList) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public TradeHistory findTradeHistorybylistnum(int listnum, String type,
			String status) {
		// TODO Auto-generated method stub
		return tradehistoryDao.gettradehistory(listnum, type, status);
	}

	@Override
	public void update(int id,BigDecimal amount, String status, String date) {
		// TODO Auto-generated method stub
		tradehistoryDao.updateTrade(id,amount, status, date);
	}
}
